![]() | The method of extending Calc by Add-Ins that is described in the following is outdated. The interfaces are still valid and supported, to ensure compatibility with existing Add-Ins, but for programming new Add-Ins you should use the new API functions.
次に説明する、アドインを使用して Calc を機能強化する方法は古いものです。インタフェースは、既存のアドインとの互換性を確保するため、まだ有効であり、サポートもされていますが新しいアドインをプログラミングするには、新しい API 関数を使用する必要があります。 |
Office Calc can be expanded by Add-Ins, which are external programming modules providing additional functions for working with spreadsheets. These are listed in the Function Wizard in the Add-In category. If you would like to program an Add-In yourself, you can learn here which functions must be exported by the shared library external DLL so that the Add-In can be successfully attached.
Office Calc はアドインで拡張できます。アドインとは、表計算ドキュメント用の関数を追加する外部プログラミングモジュールのことです。アドインは 関数ウィザード の分類項目 アドイン に表示されます。自分でアドインを作成する場合、アドインを正常に組み込むためには、どの関数を共有ライブラリ外部 DLL からエクスポートする必要があるかを学ぶ必要があります。
Office searches the Add-in folder defined in the configuration for a suitable shared library DLL. To be recognized by Office, the shared library DLL must have certain properties, as explained in the following. This information allows you to program your own Add-In for Function Wizard of Office Calc.
Office は、適切な shared library DLL の設定で定義されている Add-in フォルダを検索します。Office で認識されるように、shared library DLL は、次に説明されているとおり、一定のプロパティーを含む必要があります。この情報によって、Office Calc の 関数ウィザード 向けに独自のアドインをプログラムできます。
Each Add-In library provides several functions. Some functions are used for administrative purposes. You can choose almost any name for your own functions. However, they must also follow certain rules regarding parameter passing. The exact naming and calling conventions vary for different platforms.
各アドインライブラリには、複数の関数が用意されています。いくつかの関数は管理用です。自分で作成した関数には、規則に従った上で、任意の名前を付けることができます。しかし、パラメータの引き渡しに関する一定の規則には従う必要があります。名前の付け方やパラメータの引き渡しに関する正確な規則はプラットフォームごとに異なります。
At a minimum, the administrative functions GetFunctionCount and GetFunctionData must exist. Using these, the functions as well as parameter types and return values can be determined. As return values, the Double and String types are supported. As parameters, additionally the cell areas Double Array, String Array, and Cell Array are supported.
少なくとも、管理用の関数 GetFunctionCount と GetFunctionData が存在する必要があります。これらの関数を使用すると、関数、パラメータの種類、および戻り値を判断できます。戻り値には、Double と String を使用できます。パラメータには、Double と String 以外にも、Double 配列、String 配列、および セル配列 を使用できます。
Parameters are passed using references. Therefore, a change of these values is basically possible. However, this is not supported in Office Calc because it does not make sense within spreadsheets.
パラメータは参照として入力されます。そのため、基本的には値の変更が可能です。しかし、表計算プログラムにおいては適当でないため、Office Calc では値を変更することはできません。
Libraries can be reloaded during runtime and their contents can be analyzed by the administrative functions. For each function, information is available about count and type of parameters, internal and external function names and an administrative number.
ライブラリは実行時に読み込むことができます。このとき、管理用の関数を使用すると、ライブラリの内容を解析できます。どの関数でも、パラメータの数と種類、内部関数名と外部関数名、および管理番号についての情報が使用できます。
The functions are called synchronously and return their results immediately. Real time functions (asynchronous functions) are also possible; however, they are not explained in detail because of their complexity.
関数が同時に呼び出されすぐに結果を返します。リアルタイム関数も可能ですが、複雑なためここでは詳しく説明しません。
The maximum number of parameters in an Add-In function attached to Office Calc is 16: one return value and a maximum of 15 function input parameters.
Office Calc に組み込むことができるアドイン関数のパラメータは最大で 16 個です。そのうちの 1 個は戻り値用で、残りの 15 個は入力用です。
The data types are defined as follows:
データの種類は次のように定義されています。
|
Data types
|
Definition
|
|
CALLTYPE
|
Under Windows: FAR PASCAL (_far _pascal)
Other: default (operating system specific default)
|
|
USHORT
|
2 Byte unsigned Integer
|
|
DOUBLE
|
8 byte platform-dependent format
|
|
Paramtype
|
Platform-dependent like int
PTR_DOUBLE =0 pointer to a double
PTR_STRING =1 pointer to a zero-terminated string
PTR_DOUBLE_ARR =2 pointer to a double array
PTR_STRING_ARR =3 pointer to a string array
PTR_CELL_ARR =4 pointer to a cell array
NONE =5
|
Following you will find a description of those functions, which are called at the Shared Library external DLL.
次に、共有ライブラリ外部 DLL で呼び出せる関数について説明します。
For all Shared Library DLL functions, the following applies:
すべての 共有ライブラリDLL 関数には、次の規則が適用されます。
void CALLTYPE fn(out, in1, in2, ...)
void CALLTYPE fn(out, in1, in2,...)
Output: Resulting value
アウトプット: 結果値
Input: Any number of types (double&, char*, double*, char**, Cell area), where the Cell area is an array of types double array, string array, or cell array.
入力:型 double&、char*、double*、char**、およびセル範囲 (数は任意)。セル範囲とは、倍精度、文字列、またはセルの配列のことです。
Returns the number of functions without the management functions of the reference parameter. Each function has a unique number between 0 and nCount-1. This number will be needed for the GetFunctionData and GetParameterDescription functions later.
管理関数を含まない関数の数を参照パラメータに返します。どの関数にも 0 から nCount-1 までの番号が付いています。この番号は、後でGetFunctionData関数とGetParameterDescription関数に必要です。
Syntax
構文
void CALLTYPE GetFunctionCount(USHORT& nCount)
void CALLTYPE GetFunctionCount(USHORT& nCount)
Parameter
パラメータ
USHORT &nCount:
USHORT &nCount
Output: Reference to a variable, which is supposed to contain the number of Add-In functions. For example: If the Add-In provides 5 functions for Office Calc, then nCount=5.
アウトプット: アドイン関数の数が含まれている変数の参照。アドインが Office Calc に5つの関数を用意している場合は、nCount=5 になります。
Determines all the important information about an Add-In function.
アドイン関数に関するすべての重要な情報を定義します。
Syntax
構文
void CALLTYPE GetFunctionData(USHORT& nNo, char* pFuncName, USHORT& nParamCount, Paramtype* peType, char* pInternalName)
void CALLTYPE GetFunctionData(USHORT& nNo, char* pFuncName, USHORT& nParamCount, Paramtype* peType, char* pInternalName)
Parameter
パラメータ
USHORT& nNo:
USHORT& nNo:
Input: Function number between 0 and nCount-1, inclusively.
インプット: 0 から nCount-1 までの関数番号。
char* pFuncName:
char* pFuncName:
Output: Function name as seen by the programmer, as it is named in the Shared Library DLL. This name does not determine the name used in the Function Wizard.
出力: プログラマから見た関数名。つまり、共有ライブラリDLL に指定されている関数名。この名前は必ずしも、関数ウィザード で表示される名前ではありません。
USHORT& nParamCount:
USHORT& nParamCount
Output: Number of parameters in AddIn function. This number must be greater than 0, because there is always a result value; the maximum value is 16.
アウトプット: アドイン関数のパラメータ数。結果値は常に最低1つあり、最高16まで可能なため、0 より大きい必要があります。
Paramtype* peType:
Paramtype* peType:
Output: Pointer to an array of exactly 16 variables of type Paramtype. The first nParamCount entries are filled with the suitable type of parameter.
アウトプット: Paramtype の変数が16個ある配列を指すポインタ。最初の nParamCount 項目は、該当するパラメータのタイプで埋められます。
char* pInternalName:
char* pInternalName:
Output: Function name as seen by the user, as it appears in the Function Wizard. May contain umlauts.
出力: ユーザーから見た関数名。つまり、関数ウィザード で表示される関数名。ウムラウトも使用できます。
The pFuncName and pInternalName parameters are char arrays, which are implemented with size 256 in Office Calc.
パラメータ pFuncName と pInternalName は、Office Calc でサイズ 256 を実装した char Array です。
Provides a brief description of the Add-In function and its parameters. As an option, this function can be used to show a function and parameter description in the Function Wizard.
アドイン関数とそのパラメータについての簡単な説明を提供します。この関数は 関数ウィザード で関数とパラメータの説明を表示するのにも使用できます。
Syntax
構文
void CALLTYPE GetParameterDescription(USHORT& nNo, USHORT& nParam, char* pName, char* pDesc)
void CALLTYPE GetParameterDescription(USHORT& nNo, USHORT& nParam, char* pName, char* pDesc)
Parameter
パラメータ
USHORT& nNo:
USHORT& nNo:
Input: Number of the function in the library; between 0 and nCount-1.
インプット: ライブラリ内の関数番号 (0 から nCount-1 まで)
USHORT& nParam:
USHORT& nParam
Input: Indicates, for which parameter the description is provided; parameters start at 1. If nParam is 0, the description itself is supposed to be provided in pDesc; in this case, pName does not have any meaning.
インプット: 説明を付けるパラメータを表示します。パラメータは 1 で始まります。nParam が 0 の場合、関数自体の説明が pDesc に必要で、この場合 pName は使用しません。
char* pName:
char* pName:
Output: Takes up the parameter name or type, for example, the word "Number" or "String" or "Date", and so on. Implemented in Office Calc as char[256].
アウトプット: たとえば、「数字」、「文字列」、「日付」といった名前やパラメータの種類を取り入れます。Office Calc は char[256] として実装します。
char* pDesc:
char* pDesc:
Output: Takes up the description of the parameter, for example, "Value, at which the universe is to be calculated." Implemented in Office Calc as char[256].
アウトプット: たとえば、「宇宙を計算する値」のような、パラメータの説明を取り入れます。Office Calc は char[256] として実装します。
pName and pDesc are char arrays; implemented in Office Calc with size 256. Please note that the space available in the Function Wizard is limited and that the 256 characters cannot be fully used.
pName と pDesc は char 型の配列です。Office Calc はサイズ 256 で実装します。なお、関数ウィザード で使用できる空間は限られており、256 文字すべてを使用できるわけではないので注意が必要です。
The following tables contain information about which data structures must be provided by an external program module in order to pass cell areas. Office Calc distinguishes between three different arrays, depending on the data type.
次の表は、セル参照を入力するために、データ構造が必要とする外部プログラムモジュールを表しています。Office Calc は、データの型によってセル範囲を3種に分類します。
As a parameter, a cell area with values of the Number/Double type can be passed. A double array in Office Calc is defined as follows:
パラメータに、数値/Double 型の値を含むセル範囲が指定できます。Office Calc では、Double 配列は次のように定義されています:
|
Offset
|
Name
|
Description
|
|
0
|
Col1
|
Column number in the upper-left corner of the cell area. Numbering starts at 0.
|
|
2
|
Row1
|
Row number in the upper-left corner of the cell area; numbering starts at 0.
|
|
4
|
Tab1
|
Table number in the upper-left corner of the cell area; numbering starts at 0.
|
|
6
|
Col2
|
Column number in the lower-right corner of the cell area. Numbering starts at 0.
|
|
8
|
Row2
|
Row number in the lower-right corner of the cell area; numbering starts at 0.
|
|
10
|
Tab2
|
Table number in the lower-right corner of the cell area; numbering starts at 0.
|
|
12
|
Count
|
Number of the following elements. Empty cells are not counted or passed.
|
|
14
|
Col
|
Column number of the element. Numbering starts at 0.
|
|
16
|
Row
|
Row number of the element; numbering starts at 0.
|
|
18
|
Tab
|
Table number of the element; numbering starts at 0.
|
|
20
|
Error
|
Error number, where the value 0 is defined as "no error." If the element comes from a formula cell the error value is determined by the formula.
|
|
22
|
Value
|
8 byte IEEE variable of type double/floating point
|
|
30
|
...
|
Next element
|
A cell area, which contains values of data type Text and is passed as a string array. A string array in Office Calc is defined as follows:
データの型が文字列であるセル範囲は、String 配列として指定されます。Office Calc では、String 配列を次のように定義しています。
|
Offset
|
Name
|
Description
|
|
0
|
Col1
|
Column number in the upper-left corner of the cell area. Numbering starts at 0.
|
|
2
|
Row1
|
Row number in the upper-left corner of the cell area; numbering starts at 0.
|
|
4
|
Tab1
|
Table number in the upper-left corner of the cell area; numbering starts at 0.
|
|
6
|
Col2
|
Column number in the lower-right corner of the cell area. Numbering starts at 0.
|
|
8
|
Row2
|
Row number in the lower-right corner of the cell area; numbering starts at 0.
|
|
10
|
Tab2
|
Table number in the lower-right corner of the cell area; numbering starts at 0.
|
|
12
|
Count
|
Number of the following elements. Empty cells are not counted or passed.
|
|
14
|
Col
|
Column number of the element. Numbering starts at 0.
|
|
16
|
Row
|
Row number of the element; numbering starts at 0.
|
|
18
|
Tab
|
Table number of the element; numbering starts at 0.
|
|
20
|
Error
|
Error number, where the value 0 is defined as "no error." If the element comes from a formula cell the error value is determined by the formula.
|
|
22
|
Len
|
Length of the following string, including closing zero byte. If the length including closing zero byte equals an odd value a second zero byte is added to the string so that an even value is achieved. Therefore, Len is calculated using ((StrLen+2)&~1).
|
|
24
|
String
|
String with closing zero byte
|
|
24+Len
|
...
|
Next element
|
Cell arrays are used to call cell areas containing text as well as numbers. A cell array in Office Calc is defined as follows:
セル配列を使用すると、テキストと数値を含むセル範囲を呼び出すことができます。Office Calc のセル配列は次のように定義されています。
|
Offset
|
Name
|
Description
|
|
0
|
Col1
|
Column number in the upper-left corner of the cell area. Numbering starts at 0.
|
|
2
|
Row1
|
Row number in the upper-left corner of the cell area; numbering starts at 0.
|
|
4
|
Tab1
|
Table number in the upper-left corner of the cell area; numbering starts at 0.
|
|
6
|
Col2
|
Column number in the lower-right corner of the cell area. Numbering starts at 0.
|
|
8
|
Row2
|
Row number in the lower-right corner of the cell area; numbering starts at 0.
|
|
10
|
Tab2
|
Table number in the lower-right corner of the cell area; numbering starts at 0.
|
|
12
|
Count
|
Number of the following elements. Empty cells are not counted or passed.
|
|
14
|
Col
|
Column number of the element. Numbering starts at 0.
|
|
16
|
Row
|
Row number of the element; numbering starts at 0.
|
|
18
|
Tab
|
Table number of the element; numbering starts at 0.
|
|
20
|
Error
|
Error number, where the value 0 is defined as "no error." If the element comes from a formula cell the error value is determined by the formula.
|
|
22
|
Type
|
Type of cell content, 0 == Double, 1 == String
|
|
24
|
Value or Len
|
If type == 0: 8 byte IEEE variable of type double/floating point
If type == 1: Length of the following string, including closing zero byte. If the length including closing zero byte equals an odd value a second zero byte is added to the string so that an even value is achieved. Therefore, Len is calculated using ((StrLen+2)&~1).
|
|
26 if type==1
|
String
|
If type == 1: String with closing zero byte
|
|
32 or 26+Len
|
...
|
Next element
|